MANIPULATING VARIABLES

A variable is a specific type of information (either numeric or non-numeric) that is observed many times, and which can vary from one observation to the next. Data is a collection of variables, and is the information that you wish to visualize and analyze with ViSta.

Before visualizing or analyzing your data, and often times during the course of a statistical investigation, it is necessary to manipulate your data. ViSta has three data manipulation tools:
  1) ViVa, ViSta's Variable Language, creates and modifies variables using statements that are like algebraic equations. ViVa is easy to learn and use, but is limited in scope and can only be used in the listener. It is a special purpose language intended for manipulating ViSta variables.
  2) VAR creates and modifies variables using expressions in the Lisp language. VAR is faster and much more general than ViVaand can be entered from the listener or from files. Although VAR is based on Lisp, which is much harder to learn than ViVa, you only need to learn a small subset of Lisp to manipulate variables. But, since Lisp is a general purpose computing language and ViVa is not, VAR can be much more powerful than ViVa.
  3) DATASET creates data from a collection of variables. Note that ViVa and VAR create variables which can be further manipulated by ViVa and VAR. However, they cannot be visualized, analyzed or permanently saved until they are placed into a dataset with DATASET.


DOLLAR FUNCTIONS

ViSta has several functions that tell you what variables are available for use by ViVa, VAR and DATASET. These functions all start with the $ character, and so are called "dollar functions".

To find out what variables are available for creating new variables and forming new data objects, type

    NAME        INFORMATION
   $vars       list of variables in the current data
   $all-vars   list of all variables
   $data-vars  list of all data object variables
   $free-vars  list of all free variables
   $NAME-vars  list of all variables in data object NAME


ViVa Example:

ViVa uses algebraic equations to manipulate and create variables. The equations must be enclosed in brackets. For example, if you have measurements of temperature on the Farenheit scale used in the United States and you wish to convert them to the Celsius scale used by the rest of the world, you would type:

     [celsius = (5 / 9) * (farenheit - 32)]

The variable on the left of the equal sign is created and assigned the value of the expression on the right.


VAR Example:

You can also use VAR to manipulate existing variables and calculate new ones. VAR statements have the form:

     (VAR variable formula)

This statement creates a new variable named "variable" whose value is the result of the calculations performed by "formula". Here's how you do the temperature scale conversion example with VAR:

     (var celsius (* (/ 5 9) (- farenheit 32)))

Notice that functions (such as * / and -) always preceed their arguments.


DATASET Example:

DATASET takes a collection of variables and makes a new dataobject from them. The dataobject persists throughout the session with ViSta and can be permanently saved to a file. The variables in the dataset can be visualized and analyzed with ViSta.

For example, to put the two temperature scales in a datafile you type:

   (dataset both-scales celsius farenheit)

The general form of the DATASET statement is

   (DATASET NAME VAR1 VAR2 ...
            :TYPES '("numeric" "category" ...)
            :LABELS '("A" "B" "C" "D" ...)
            )

The :TYPES and :LABELS keywords are used to specify variable types and observation names. These arguments are optional, although you must use :TYPES when you have categorical variables.
